import numpy as np
import talib
import pandas as pd

# 模拟价格数据
data = {
    "close": [
        100,
        101,
        102,
        103,
        104,
        105,
        106,
        107,
        108,
        109,
        110,
        108,
        107,
        106,
        105,
        104,
        103,
        102,
        101,
        100,
    ],
    "high": [
        101,
        102,
        103,
        104,
        105,
        106,
        107,
        108,
        109,
        110,
        111,
        109,
        108,
        107,
        106,
        105,
        104,
        103,
        102,
        101,
    ],
    "low": [
        99,
        100,
        101,
        102,
        103,
        104,
        105,
        106,
        107,
        108,
        107,
        106,
        105,
        104,
        103,
        102,
        101,
        100,
        99,
        98,
    ],
    "open": [
        99.5,
        100.5,
        101.5,
        102.5,
        103.5,
        104.5,
        105.5,
        106.5,
        107.5,
        108.5,
        109.5,
        108.5,
        107.5,
        106.5,
        105.5,
        104.5,
        103.5,
        102.5,
        101.5,
        100.5,
    ],
}

df = pd.DataFrame(data)

# 计算高点和低点突破
high_breakout = df["high"].shift(1) < 105  # 假设突破高点为 105
low_breakout = df["low"].shift(1) > 95  # 假设突破低点为 95

# 计算突破后的回调
high_pullback = (df["low"] < df["high"].shift(1)) & high_breakout
low_pullback = (df["high"] > df["low"].shift(1)) & low_breakout

print("高点突破：", high_breakout)
print("高点回调：", high_pullback)
print("低点突破：", low_breakout)
print("低点回调：", low_pullback)
